#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int missingNumber(vector<int>& nums)
    {
        int ret = 0;
        for (auto& ch : nums)
        {
            ret ^= ch;
        }
        for (int i = 0; i <= nums.size(); i++)
        {
            ret ^= i;
        }
        return ret;
    }
};

//class Solution
//{
//public:
//    int missingNumber(vector<int>& nums)
//    {
//        int sum = 0;
//        for (auto& ch : nums)
//            sum += ch;
//        return (nums.size() * (nums.size() + 1)) / 2 - sum;
//    }
//};